The DbProviderFactory looks in the .NET configuration file for a specific configuration section called "dataAccess". You must define this section at the top of the configuration file in the "configSections" element. Following the conficSection comes the "dataAccess" element which will containing the "provider" elements.
For example:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="dataAccess" type="FChoice.Common.Data.DataAccessSectionHandler, FChoice.Common"/> <!-- other config sections if present --> </configSections> <dataAccess> <provider alias="ODPNet" type="FChoice.DataProviders.ODPNet.ODPOracleProvider, FChoice.DataProviders.ODPNet"/> </dataAccess> <!-- rest of config file --> </configuration>
In the example a single custom DbProvider is defined using the using the "provider" element. It is possible to configure one or more providers in this way.
The fcSDK includes a custom provider which uses the Oracle™ Data Provider for .NET rather than the Microsoft ADO.NET provider for Oracle which ships with the .NET Framework. If you wish to use this provider, refer to the configuration example above.
This table describes the attributes required for the provider element.
Attribute | Required | Description |
---|---|---|
alias | Yes |
A key used by DbProviderFactory to distinguish this provider. An instance of the DbProvider can be created and loaded by
DbProviderFactory by calling DbProviderFactory.CreateProvider method.
Be careful not to use one of the built in aliases that are always present:
|
type | Yes |
The fully qualified type name of a class which derrives from FChoice.Common.DbProvider.
NOTE: Please refer to the Type.GetType method documentation for information for the specific format of the value of this attribute. |
There is an application configuration setting, "fchoice.dbprovider.configurationfile", which allows the fcSDK to bypass the application configuration file and directly use another xml file to configure the database Providers.
This example shows an example fc.env used by many First Choice Software applications to tell the fcSDK where to look for the remote session configuration file.
;begin fc.env file... ; ... other settings ... fchoice.dbprovider.configurationfile=c:\app\fcclient\dbprovider.config
To facilitate extensibility the fcSDK provider mechanism is a plug-in type mechanism which depends on loading classes at runtime. In the examples above a "partially qualified" class name is used only specifying the name of the class and the assembly (dll) where that class can be found. This usually works fine for pure dotnet scenarios. When running Compatiblity layer applications needing to configure custom dbproviders the configuration file must use fully qualified class names. The table below shows the fully qualified name (with version number missing) of the custom providers that come with the fcSDK.
Name | Fully Qualified Type Name (type=...) | Description |
---|---|---|
ODP.NET | FChoice.DataProviders.ODPNet.ODPOracleProvider, FChoice.DataProviders.ODPNet, Version=x.x.x.x, Culture=neutral, PublicKeyToken=48c955ba8dfd90d8 | Alternative Oracle DbProvider allowing access to Oracle 8i databases and above. |
The following example shows the contents of a configuration file using fully qualified names.
<dataAccess> <provider alias="ODPNet" type="FChoice.DataProviders.ODPNet.ODPOracleProvider, FChoice.DataProviders.ODPNet, Version=2.0.0.8, Culture=neutral, PublicKeyToken=48c955ba8dfd90d8"/> </dataAccess>